/* =========================================
   IMPORTAZIONI E IMPOSTAZIONI GLOBALI
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Shantell+Sans&display=swap');

html {
    scroll-behavior: smooth; /* Scorrimento fluido per tutta la pagina */
}

body {
    margin: 0;
    background-color: #000000;
    height: 100vh;
}

/* Stile base per testi e immagini */
h1, h2, h3, .titolo-anime {
    font-family: 'Comic Neue', cursive, sans-serif;
}

img {
    max-width: 100%;
    height: auto;
}



/* =========================================
   SCROLLBAR E SELEZIONE TESTO (STILE PRO)
   ========================================= */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #000000;
    border-left: 1px solid #222;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, darkorange, orange);
    border-radius: 6px;
    border: 2px solid #000000;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ff4500, #ff8c00);
}

::selection {
    background-color: orange;
    color: black;
    text-shadow: none;
}
::-moz-selection {
    background-color: orange;
    color: black;
}

/* =========================================
   PULSANTI SCORRIMENTO (SU E GIÙ)
   ========================================= */
#scroll-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column; /* Le mette una sopra l'altra */
    gap: 15px; /* Spazio tra la freccia su e giù */
    z-index: 9999 !important;
    
    /* Animazione fluida per la comparsa */
    transition: opacity 0.3s ease-in-out, transform 0.3s ease;
    
    /* STATO INIZIALE: NASCOSTO */
    opacity: 0; 
    pointer-events: none; /* Non cliccabili quando invisibili */
    transform: translateY(20px); /* Partono leggermente più in basso */
}

/* Quando aggiungiamo questa classe tramite JS, i pulsanti appaiono */
#scroll-buttons.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#scroll-buttons img {
    width: 50px;  /* Puoi aumentare o diminuire la grandezza da qui */
    height: 50px;
    cursor: pointer;
    border-radius: 50%; /* Essendo rotonde, applichiamo un raggio perfetto */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6); /* Una bella ombra per staccarle dallo sfondo nero */
    transition: transform 0.2s;
}

/* =========================================
   EFFETTI HOVER E CLICK (FIX PER TELEFONI)
   ========================================= */

/* 1. Questo si attiva SOLO sui dispositivi col mouse (PC) */
@media (hover: hover) {
    #scroll-buttons img:hover {
        transform: scale(1.1);
        box-shadow: 0 4px 15px rgba(255, 165, 0, 0.8);
    }
}

/* 2. Questo si attiva nel momento esatto in cui fai TAP col dito o CLIC col mouse */
#scroll-buttons img:active {
    transform: scale(0.95); /* Rimpicciolisce leggermente la freccia dando la sensazione del click */
    box-shadow: 0 2px 5px rgba(255, 165, 0, 0.5); /* Alone più piccolo e rapido */
}

/* =========================================
   BARRA DI RICERCA MODERNA
   ========================================= */
.search-container {
    position: relative;
    display: inline-block;
}

#searchInput {
    background-color: #111;
    border: 1px solid #444;
    color: white;
    padding: 10px 15px 10px 35px;
    border-radius: 20px;
    font-size: 16px;
    transition: width 0.4s ease-in-out, border-color 0.3s;
    width: 200px;
    font-family: inherit;
}

#searchInput:focus {
    width: 350px;
    border-color: orange;
    outline: none;
}

#searchButton {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #888;
    font-size: 16px;
    pointer-events: none;
}

/* =========================================
   SEZIONE SERIE TV (GRIGLIA)
   ========================================= */
.anime-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    padding: 20px 40px;
    max-width: 1600px;
    margin: 0 auto;
}

.anime-card {
    background-color: #111;
    border: 1px solid #333;
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
    
    /* Scroll Reveal (inizialmente invisibile) */
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.anime-card.show {
    opacity: 1;
    transform: translateY(0);
}

.anime-card:nth-child(2) { transition-delay: 0.1s; }
.anime-card:nth-child(3) { transition-delay: 0.2s; }
.anime-card:nth-child(4) { transition-delay: 0.3s; }

.anime-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(255, 165, 0, 0.2);
    border-color: orange;
    z-index: 10;
}

.card-image-wrapper {
    width: 100%;
    height: 220px;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid #333;
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    background-color: #000; 
    transition: transform 0.5s ease;
}

.anime-card:hover .card-image-wrapper img {
    transform: scale(1.1);
}

.card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: orange;
    color: black;
    font-weight: bold;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Comic Sans MS', sans-serif;
    box-shadow: 0 2px 5px rgba(0,0,0,0.8);
    font-size: 18px;
    z-index: 2;
}

.card-content {
    padding: 20px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-content h3 {
    margin: 0 0 10px 0;
    color: white;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 22px;
    line-height: 1.2;
}

.card-content .genre {
    color: #aaa;
    font-size: 15px;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-style: italic;
}

/* =========================================
   TABELLA E LISTA ANIME (FLIP CARDS)
   ========================================= */
ol {
    padding-left: 0 !important;
    margin-left: 0 !important;
    list-style-position: inside !important;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 !important;
    padding: 0 !important;
}

td {
    padding: 0 !important;
    margin: 0 !important;
}

ol li {
    font-family: 'Comic Sans MS', cursive, sans-serif !important;
    font-size: 27px !important;
    font-weight: bold;
    color: white;
    margin-top: 30px;
    margin-bottom: 20px;
    padding-left: 5px;
}

#right p {
    font-family: 'Comic Sans MS', cursive, sans-serif !important;
    font-size: 25px !important;
    color: white;
    text-align: right;
    padding-right: 20px;
}

.riga-anime {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
}

/* Stili Flash Card (Effetto rotazione) */
.container {
    width: 100%;
    height: 100%;
    font-size: 20px;
    font-family: "Shantell Sans", cursive;
    text-transform: uppercase;
    gap: 30px;
    padding-bottom: 20px;
}

.card {    
    position: relative;
    transform-style: preserve-3d;
    cursor: pointer;
    max-width: 100% !important;
}

.face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transition: all 0.8s ease;
    border-radius: 10%;
    overflow: hidden; 
}

.front {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: black;
}

.front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10%;
}

.back {
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center; 
    justify-content: flex-start; 
    background-size: cover; 
    background-position: center; 
    background-attachment: scroll; 
    position: relative; 
    z-index: 1;
    border-radius: 10%; 
    padding: 10px; 
    box-sizing: border-box;
}

.back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: -1;
    border-radius: 10%;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.back p {
    position: relative;
    z-index: 2;
    height: 100%; 
    width: 100%; 
    overflow-y: auto;
    color: white;
    font-size: 20px;
    line-height: 1.5;
    text-transform: none;
    text-align: center;
    margin: 0; 
    padding: 0;
    box-sizing: border-box;
    background-image: none;
}

.card:hover .front { transform: rotateY(180deg); }
.card:hover .back { transform: rotateY(0); }

/* =========================================
   FORM AGGIUNGI ANIME
   ========================================= */
.add-section {
    background-color: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 30px;
    margin: 30px auto;
    border-radius: 15px;
    border: 1px solid rgba(255, 165, 0, 0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 800px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.add-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.add-form input, .add-form textarea {
    background-color: #222;
    border: 1px solid #444;
    color: white;
    padding: 12px;
    border-radius: 5px;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
}

.full-width { grid-column: span 2; }

.genre-selector-container {
    grid-column: span 2;
    background: #1a1a1a;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #444;
}

.genre-label { display: block; margin-bottom: 10px; color: #aaa; font-weight: bold; }

.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.genre-tags::-webkit-scrollbar { width: 8px; }
.genre-tags::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }

.genre-tag {
    background-color: #333;
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.genre-tag:hover { background-color: #555; }
.genre-tag.selected { background-color: orange; color: black; font-weight: bold; }

.btn-add {
    background-color: orange;
    color: black;
    font-weight: bold;
    border: none;
    cursor: pointer;
    padding: 15px;
    border-radius: 5px;
    grid-column: span 2;
    font-size: 18px;
    text-transform: uppercase;
    transition: transform 0.2s;
}
.btn-add:hover { background-color: #ff9800; transform: scale(1.02); }

@keyframes pulse-orange {
    0% { box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 165, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 165, 0, 0); }
}

.btn-toggle-form {
    background-color: transparent;
    color: orange;
    border: 2px solid orange;
    padding: 12px 25px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: pulse-orange 2s infinite;
}

.btn-toggle-form:hover {
    background-color: orange;
    color: black;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.5);
}

/* =========================================
   SEZIONE COMMENTI (SIDEBAR)
   ========================================= */
#commenti-header {
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 20px;
    box-sizing: border-box;
    z-index: 9999;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#commenti-contenuto {
    overflow-y: auto;
}

#commenti-button {
    position: fixed; 
    top: 30px;
    right: 20px;
    color: white;
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    z-index: 9999;
}

#commenti-sezione {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100%;
    background-color: rgba(10, 10, 10, 0.85); 
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transition: right 0.3s ease-in-out;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    z-index: 999;
}

#commenti-sezione.aperto {
    right: 0;
}

#commenti-button, #chiudi-commenti, #invia-commento {
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    box-shadow: 0 0 5px 2px rgba(255, 0, 0, 0.5);
    cursor: pointer;
}

#commento-input {
    background-color: #222;
    color: white;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 0 5px 2px rgba(255, 0, 0, 0.5);
}

/* =========================================
   FOOTER (PIÈ DI PAGINA)
   ========================================= */
.site-footer {
    width: 100%;
    padding: 40px 0;
    margin-top: 50px;
    background-color: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #333;
    position: relative;
    text-align: center;
}

.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, orange, transparent);
    box-shadow: 0 -2px 10px orange;
}

.footer-content p {
    margin: 5px 0;
    font-family: 'Segoe UI', sans-serif;
    color: white;
    font-size: 16px;
    letter-spacing: 1px;
}

.footer-links {
    margin-top: 15px;
}

.footer-links a {
    color: #aaa;
    text-decoration: none;
    margin: 0 10px;
    font-size: 14px;
    transition: color 0.3s;
    font-family: sans-serif;
}

.footer-links a:hover {
    color: orange;
    text-shadow: 0 0 5px orange;
}

/* =========================================
   ANIMAZIONI: MARQUEE (SCORRIMENTO) MODERNO
   ========================================= */
.marquee-modern {
    width: 100%;
    overflow: hidden;
    display: block;
    background-color: #000;
    padding: 10px 0;
}

.marquee-track {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap; 
    width: max-content;
    align-items: center;
    animation: scorri 30s linear infinite;
}

.marquee-track img {
    width: 250px;
    height: 150px;
    object-fit: cover;
    flex-shrink: 0;
    margin-right: 20px;
    border-radius: 10px;
    display: block;
}

.marquee-modern:hover .marquee-track {
    animation-play-state: paused;
}

@keyframes scorri {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* =========================================
   ANIMAZIONI: CAROSELLO 3D RESPONSIVE
   ========================================= */
.carousel-wrapper {
    display: flex; 
    justify-content: center; 
    width: 100%; 
    padding: 50px 0;
    perspective: 1000px; /* Profondità 3D */
    overflow: visible; /* Fondamentale per non tagliare il 3D */
}

.carousel {
    position: relative;
    transform-style: preserve-3d;
    animation: rotate 15s infinite linear;
    width: 200px;
    height: 200px;
}

.c-item {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 165, 0, 0.4);
}

.c-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.c-item:nth-child(1) { transform: rotateY(0deg) translateZ(200px); }
.c-item:nth-child(2) { transform: rotateY(72deg) translateZ(200px); }
.c-item:nth-child(3) { transform: rotateY(144deg) translateZ(200px); }
.c-item:nth-child(4) { transform: rotateY(216deg) translateZ(200px); }
.c-item:nth-child(5) { transform: rotateY(288deg) translateZ(200px); }

@keyframes rotate { 
    from { transform: rotateY(0deg); } 
    to { transform: rotateY(360deg); } 
}


/* =========================================
   🛠 REGOLE RESPONSIVE E FIX PER SMARTPHONE 🛠
   Tutto quello che deve adattarsi sugli schermi 
   più piccoli è concentrato qui sotto!
   ========================================= */

@media screen and (max-width: 768px) {
    
    /* FIX LISTA E TABELLA ANIME */
    /* 1. Forza la tabella a smettere di comportarsi da tabella */
    table, tbody, td {
        display: block !important;
        width: 100% !important;
    }
    
    /* Separato il "tr" per rimuovere l'!important e permettere alla barra di ricerca (JS) di nasconderlo */
    tr {
        display: block;
        width: 100% !important;
    }

    #animeTable tr {
        margin-bottom: 40px;
        padding-bottom: 20px;
        border-bottom: 1px solid #333;
    }

    #animeTable td {
        text-align: center !important;
    }

    .container .card {
        width: 100% !important; 
        height: 250px !important;
        margin: 0 auto !important;
    }

    #right {
        margin-top: 15px;
        text-align: center !important;
    }

    #right p, .testo-generi {
        font-size: 20px !important;
        padding-right: 0 !important;
        text-align: center !important;
        padding: 10px 0;
        width: 100%;
    }

    ol li {
        text-align: left;
        margin-left: 20px;
        margin-bottom: 10px;
    }

    .riga-anime {
        flex-direction: column;
        text-align: center;
    }
    
    /* Elimina i margini vuoti a sinistra sui telefoni */
    div[style*="margin-left:30px"] {
        margin-left: 0 !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* FIX VIDEO 400 ANIME */
    video {
        max-width: 100% !important;
        height: auto !important;
        box-sizing: border-box;
    }
    #edit-400-container {
        padding: 20px 10px !important;
    }

    /* FIX FORM AGGIUNGI ANIME (1 Colonna) */
    .add-form {
        grid-template-columns: 1fr !important;
    }
    .full-width, .genre-selector-container, .btn-add, #adminPassword {
        grid-column: span 1 !important;
    }
    .add-section {
        margin: 20px 15px !important;
        width: auto !important;
    }

    /* FIX BARRA DI RICERCA */
    .search-container {
        width: 90% !important;
        margin: 0 auto !important;
        display: block !important;
    }
    
    #searchInput {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #sortOrder {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 15px !important;
        box-sizing: border-box !important;
    }

    /* FIX MARQUEE MODERNO (Immagini più piccole) */
    .marquee-track img {
        width: 180px; 
        height: 110px;
        margin-right: 10px;
    }

    /* FIX CAROSELLO 3D (Rimpicciolito per non sbordare) */
    .carousel, .c-item {
        width: 130px;
        height: 130px;
    }
    
    .c-item:nth-child(1) { transform: rotateY(0deg) translateZ(130px); }
    .c-item:nth-child(2) { transform: rotateY(72deg) translateZ(130px); }
    .c-item:nth-child(3) { transform: rotateY(144deg) translateZ(130px); }
    .c-item:nth-child(4) { transform: rotateY(216deg) translateZ(130px); }
    .c-item:nth-child(5) { transform: rotateY(288deg) translateZ(130px); }
}

/* Fix extra per schermi piccolissimi (meno di 600px) */
@media screen and (max-width: 600px) {
    .search-container {
        margin-bottom: 10px;
    }
}

/* =========================================
   FORZA FONT CARTOON SU SMARTPHONE
   ========================================= */
@media screen and (max-width: 768px) {
    
    /* 1. Titoli delle Serie TV (griglia) e Titoli degli Anime (lista) */
    .card-content h3, 
    ol li {
        font-family: 'Comic Sans MS', 'Comic Neue', cursive, sans-serif !important;
    }

    /* 2. Generi (solo degli anime, il testo sotto l'immagine) */
    #right p, 
    .testo-generi {
        font-family: 'Comic Sans MS', 'Comic Neue', cursive, sans-serif !important;
    }

    /* 3. Trame (il testo che compare dietro le flash card quando si girano) */
    .back p {
        font-family: 'Comic Sans MS', 'Comic Neue', cursive, sans-serif !important;
    }

    /* 4. Titolo del video "Edit 400 anime visti" */
    #edit-400-container h2 {
        font-family: 'Comic Sans MS', 'Comic Neue', cursive, sans-serif !important;
    }
}

/* =========================================
   TASTO COMMENTI NEL FOOTER SU MOBILE
   ========================================= */

/* Su PC nascondiamo il separatore "|" dei commenti perché il bottone vola in alto a destra */
#sep-commenti {
    display: none;
}

@media screen and (max-width: 768px) {
    /* Spegne le regole del bottone fisso e lo mimetizza con il footer */
    #commenti-button {
        position: static !important; /* Annulla il fixed, facendolo restare nel footer */
        background: transparent !important; /* Toglie lo sfondo scuro */
        box-shadow: none !important; /* Toglie l'alone rosso */
        color: #aaa !important; /* Stesso grigio degli altri link */
        padding: 0 !important;
        margin: 0 5px !important;
        font-size: 14px !important;
        font-family: sans-serif !important;
        display: inline-block !important;
    }

    /* Effetto arancione se ci clicchi/passi sopra */
    #commenti-button:hover, #commenti-button:active {
        color: orange !important;
        text-shadow: 0 0 5px orange !important;
    }

    /* Su telefono accendiamo il separatore "|" per omogeneità */
    #sep-commenti {
        display: inline;
        color: #aaa;
        margin: 0 5px;
    }
}